package com.question.service.impl;

import java.sql.SQLException;

import com.question.Design.SingletonMode;
import com.question.dao.ISeedtimeDao;
import com.question.entity.User;
import com.question.service.ISeedtimeService;

public class SeedtimeServiceImpl implements ISeedtimeService {

	private ISeedtimeDao seedtimeDao = SingletonMode.getSeedtimeDao();
	@Override
	public boolean existUserByUsername(String username) {
		Long state = 0L;
		try {
			state = seedtimeDao.existUserByUsername(username);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return state == 0L;
	}
	@Override
	public void signup(User user) {
		try {
			seedtimeDao.signup(user);
		}catch(SQLException e) {
			e.printStackTrace();
		}
	}
	@Override
	public User login(User user) {
		User reUser = null;
		try {
			reUser= seedtimeDao.login(user);
		}catch(SQLException e) {
			e.printStackTrace();
		}
		return reUser;
	}
}
